const path = require('path');
//这个插件的两个作用
const htmlWebpackPlugin = require('html-webpack-plugin');
const webpackConfig = {
    entry: path.join(__dirname,'./src/main.js'),
    output: {
        filename: 'bundle.js',
        path: path.resolve(__dirname, './dist')
    },
    mode: 'development',

    plugins:[
        new htmlWebpackPlugin({
            //在内存里生成首页HTML的插件
            template: path.join(__dirname,'./src/index.html'),//指定的模板页面
            filename: 'index.html'    //指定生成的页面的名称 
        })
    ],

    module:{//这个节点用于配置所有第三方的加载器
        rules:[//匹配规则 
            { test:/\.css$/, use:['style-loader', 'css-loader'] },//配置css的加载器
            { test:/\.less$/, use:['vue-style-loader', 'css-loader', 'less-loader'] },//配置less
            { test:/\.scss$/, use:['style-loader', 'css-loader', 'sass-loader'] },//配置scss
            { test:/\.(jpg|jpeg|png|gif|bmp)$/, use:['url-loader?limit=214&name=[hash:8]-[name].[ext]'] },
            { test:/\.(ttf|eot|svg|woff|woff2)$/, use:'url-loader' },
            { test:/\.js$/, use:'babel-loader', exclude:/node_modules/ },
            {
              test: /\.vue$/,
              loader: 'vue-loader',
              options: {
                    loaders: {
                        // Customize to your liking
                        js: 'babel-loader',
                        scss: [
                            'style-loader',
                            'css-loader',
                            'sass-loader'
                        ]
                    }
                }
            }
        ]
            
    },
    resolve:{
        alias: {
            'vue$': 'vue/dist/vue.esm.js'
        },

    }

} // 原来的 webpack.base.js 配置

const vuxLoader = require('vux-loader')

module.exports = vuxLoader.merge(webpackConfig, {
    options: {},
    plugins: [
        {name: 'vux-ui'},
        {name: 'duplicate-style'},
        {
            name: 'i18n',
            vuxStaticReplace: false,
            staticReplace: false,
            extractToFiles: 'src/locales/components.yml',
            localeList: ['en', 'zh-CN']
        }
    ],
    resolve: {
        extensions: ['', '.js', '.vue', '.json']
    }
}) 